//
//  HttpUserPageConstructor.m
//  iengage
//
//  Created by Luis Ziliani on 2/24/09.
//  Copyright 2009 Manas. All rights reserved.
//

#import "HtmlUserPageConstructor.h"

#import "Util.h"

@implementation HtmlUserPageConstructor

@synthesize html;

- (id) init {
	id res = [super init];
	html = [[NSMutableString alloc] initWithString:@"<html>"];
	return res;
}

- (void) dealloc {
	[html release];
	
	[super dealloc];
}

- (void) appendHeader {
	[html appendString:@"<head></head>"];
}

- (void) startBody {
	[html appendString:@"<body>"];
}

- (void) appendImageWithData: (NSString *)data {
	[html appendString:@"<img src='data:image/jpg;base64, "];
	[html appendString:data];
	[html appendString:@"' alt='' /><br><br>"];
}

- (void) appendUserMessage: (NSString *)msg {
	[html appendString:@"<b>Said:</b><br>"];
	[html appendString: [msg toHTML]];
	[html appendString:@"<br>"];
}

- (void) appendUserMessageDateDifference: (NSString *)dateDiff {
	[html appendString:[dateDiff toHTML]];
}

- (void) appendMapImageWithLatitude: (double) latitude longitude: (double) longitude andMark:(NSString*) markChar {
	[html appendString:@"<img src='http://maps.google.com/staticmap?center="];
	NSString * locationString = [NSString stringWithFormat:@"%.12f,%.12f", latitude, longitude];
	[html appendString:locationString];
	[html appendString:@"&amp;zoom=14&amp;size=256x256&amp;maptype=mobile&amp;markers="];
	[html appendString:locationString];
	[html appendString:@",blue"];
	[html appendString:[markChar lowercaseString]];
	[html appendString:@"&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSsTL4WIgxhMZ0ZK_kHjwHeQuOD4xQJpBVbSrqNn69S6DOTv203MQ5ufA' alt='User location' />"];
}

- (void) endBody {
	[html appendString:@"</body>"];
}

- (void) end {
	[html appendString:@"</html>"];
}

@end
